package com.baidu.day5.Goods;

import java.util.ArrayList;
import java.util.Scanner;

public class Test01 {
    public static void main(String[] args) {
        Goods goods = new Goods();
        GoodServices goodServices = new GoodServices();
        ArrayList<Goods> list = new ArrayList<>();


        System.out.println("==============欢迎使用超市管理系统==================");
        while (true) {
            System.out.println("请输入您要进行的操作 1.查看商品   2.添加商品  3.删除商品  4.退出");
            Scanner sc = new Scanner(System.in);
            String userPut = sc.next();
            switch (userPut) {
                case "1":
                    System.out.println("查看商品");
                    goodServices.findAll();
                    break;
                case "2":
                    System.out.println("请输入你要添加的商品编号:");
                    Integer addNum = sc.nextInt();
                    System.out.println("请输入你要添加的商品名称:");
                    String addName = sc.next();
                    System.out.println("请输入你要添加的商品价格:");
                    Double addPrice = sc.nextDouble();
                    System.out.println("请输入你要添加的商品库存:");
                    Integer addStock = sc.nextInt();
                    Goods newGoods = new Goods(addNum, addName, addPrice, addStock);
                    boolean flag = GoodServices.addGoods(newGoods);
                    if (flag) {
                        System.out.println("添加成功");
                    } else {
                        System.out.println("添加失败");
                    }

                    break;
                case "3":
                    System.out.println("请输入你要删除商品的编号");
                    int inputNum = sc.nextInt();
                    GoodServices.deleteGoods(inputNum);
                    break;

                case "4":
                    System.exit(0); // 正常退出


            }

        }


    }
}
